#include "stdafx.h"

#include "common.h"

GLvoid glPerspective( GLdouble pFovy, GLdouble pAspect, GLdouble pzNear, GLdouble pzFar )
{
   GLdouble xmin, xmax, ymin, ymax;

   ymax = pzNear * tan( pFovy * M_PI / 360.0 );
   ymin = -ymax;
   xmin = ymin * pAspect;
   xmax = ymax * pAspect;

   glFrustum( xmin, xmax, ymin, ymax, pzNear, pzFar );
}

GLvoid glResize( const GLsizei pWidth, const GLsizei pHeight )
{
    if( pHeight == 0 || pWidth == 0 )
    {
        return;
    }
 
    /*glViewport( 0, 0, pWidth, pHeight );
 
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
 
    glOrtho( -20.0f, 20.0f, -20.0f, 20.0f, 0.0f, 1.0f );
    //glPerspective( 90.0f, (GLfloat) pWidth / (GLfloat) pHeight, 0.1f, 100.0f );
 
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();*/

    glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho( -32.0f, 32.0f, 20, -20.0f, -1, 1 );
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
}